<template>
  <div class="circle">
    <img v-if="props.src" :src="props.src" class="w-40px h-40px" />
    <div v-else class="char">{{ firstChar }}</div>
  </div>
</template>

<script setup lang="ts">
const props = defineProps({
  src: { type: String },
  name: { type: String }
})

const firstChar = computed(() => {
  if (props.name) {
    return props.name.substring(0, 1)
  } else {
    return ''
  }
})
</script>

<style lang="scss" scoped>
.circle {
  overflow: hidden;
}
.char {
  text-align: center;
  line-height: 40px;
  font-size: 1.6rem;
  color: #fff;
  font-weight: bold;
  background-color: #3aa1a2;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
}
</style>
